<?php
require_once(dirname(__FILE__) . '/inc/config.inc.php');
require_once "function.php";
$time = time();
$type = isset($_GET['type']) ? htmlspecialchars($_GET['type']) : "";
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$index = isset($_GET['index']) ? intval($_GET['index']) : 0;


//获取 签到 历史记录
if ($type == "order") {
    $sql = "SELECT *  FROM `#@__order_log` WHERE `id`=$id  ";
}
if ($type == "project") {
    $sql = "SELECT *  FROM `#@__project_log` WHERE `id`=$id  ";
}
if ($type == "visit") {
    $sql = "SELECT *  FROM `#@__visit` WHERE `id`=$id  ";
}


$order = $dosql->GetOne($sql);
$photo = array();

if (is_array($order) && isset($order['id'])) {

    //完修图片
    $op = "图片";
    if($type!="visit"){
        $picurl_arr = json_decode($order['picurls'], true);
    }else{
        $picurl_arr = json_decode($order['picfiles'], true);
    }



    if ($type == "order") {
        if ($order['qiandao'] == "true") {
            $op = "签到图片";
        }
        if ($order['fankui'] == "true") {
            $op = "反馈图片";
        }
        if ($order['wanxiu'] == "1") {
            $op = "完成图片";
        }
    }


    if ($type == "project") {
        if ($order['signIn'] == "1") {
            $op = "施工签到";
        }
        if ($order['qiantui'] == "1") {
            $op = "施工签退";
        }
        if ($order['wanxiu'] == "1") {
            $op = "工程竣工";
        }
    }
    if ($type == "project") {

        $op = "拜访图片";

    }

    $yuangong = "";
    $m_str = $order['manageid'];
    $m_arr = explode(",", $m_str);
    foreach ($m_arr as $key => $val) {
        $yuangong .= getManage($val);
    }


    foreach ($picurl_arr as $v) {
        $photo['data'][] = array('alt' => $yuangong . ' ' . $op, 'pid' => '', 'src' => $v);
    }

    $photo['start'] = $index;
    if($type!="visit"){
        $photo['title'] = date("Y-m-d H:i:s", $order['op_time']);
    }else{
        $photo['title'] = date("Y-m-d H:i:s", $order['post_time']);
    }

    $photo['id'] = $order['id'];

}
$row_arr['code'] = 0;
$row_arr['msg'] = "ok";
$row_arr['data'] = $photo;
$row_arr['sql'] = $sql;
echo json_encode($row_arr, JSON_UNESCAPED_UNICODE);

?>
